<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%divided_payments_order_log}}".
 *
 * @property integer $id
 * @property integer $divided_payments_order_id
 * @property integer $time
 * @property string $post_data
 * @property string $divided_payments_order_data
 * @property string $send_return_msg
 * @property integer $old_status
 * @property integer $new_status
 * @property string $api_return_code
 * @property string $api_return_msg
 * @property string $serial_number
 *
 * @property DividedPaymentsOrder $dividedPaymentsOrder
 */
class DividedPaymentsOrderLog extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%divided_payments_order_log}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['divided_payments_order_id', 'time', 'serial_number'], 'required'],
            [['divided_payments_order_id', 'time', 'old_status', 'new_status'], 'integer'],
            [['post_data', 'divided_payments_order_data'], 'string'],
            [['send_return_msg', 'api_return_code'], 'string', 'max' => 10],
            [['api_return_msg'], 'string', 'max' => 200],
            [['serial_number'], 'string', 'max' => 20],
            [['divided_payments_order_id'], 'exist', 'skipOnError' => true, 'targetClass' => DividedPaymentsOrder::className(), 'targetAttribute' => ['divided_payments_order_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'divided_payments_order_id' => 'Divided Payments Order ID',
            'time' => 'Time',
            'post_data' => 'Post Data',
            'divided_payments_order_data' => 'Divided Payments Order Data',
            'send_return_msg' => 'Send Return Msg',
            'old_status' => 'Old Status',
            'new_status' => 'New Status',
            'api_return_code' => 'Api Return Code',
            'api_return_msg' => 'Api Return Msg',
            'serial_number' => 'Serial Number',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getDividedPaymentsOrder()
    {
        return $this->hasOne(DividedPaymentsOrder::className(), ['id' => 'divided_payments_order_id']);
    }
}
